/*
 * @lc app=leetcode.cn id=14 lang=java
 *
 * [14] 最长公共前缀
 */

// @lc code=start
class Solution {
    public String longestCommonPrefix(String[] strs) {
        char[][] strs_array=new char[strs.length][];
        StringBuilder builder=new StringBuilder();
        int min_size=Integer.MAX_VALUE;
        for (int i = 0; i < strs_array.length; i++) {
            strs_array[i]=strs[i].toCharArray();
            min_size=Math.min(min_size,strs_array[i].length);
        }
        char[] base=strs_array[0];
        for (int i = 0; i < min_size; i++) {
            for (char[] cs : strs_array) {
                if (cs[i]!=base[i]) {
                    return builder.toString();
                }
                
            }
            builder.append(base[i]);
            
        }

        return builder.toString();
    }
}
// @lc code=end

